package vn.com.bookstore.activity;

import vn.com.bookstore.Config;
import vn.com.bookstore.ConnectActivity;
import vn.com.bookstore.R;
import vn.com.bookstore.network.NetworkAdapter;
import vn.com.bookstore.network.NetworkAdapter.OnNetworkListener;
import vn.com.bookstore.util.textview.JustifiedTextView;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.Toast;

public class HelpActivity extends ConnectActivity implements OnNetworkListener{
	JustifiedTextView tvIntroduction;
	@Override
	protected void onCreate(Bundle arg0) {
		super.onCreate(arg0);
		setContentView(R.layout.activity_help);
		
		setTitle(getString(R.string.app_name), getString(R.string.help));
		
		findViewById();
		
		tvIntroduction.setText(getString(R.string.help_introduction));
		tvIntroduction.setTextSize(16);
		
		
	}
	
	@Override
	protected void findViewById() {
		tvIntroduction = (JustifiedTextView)findViewById(R.id.tv_introduction);
		
	}
	
	public void btnClicked(View v){
		switch (v.getId()) {
		case R.id.btn_send:
			EditText edit = (EditText)findViewById(R.id.edt_feedback);
			final String feedText = edit.getText().toString();
			if(feedText.length()<1) return;
			
			// get list of Banner
			new Thread() {
				public void run() {
					NetworkAdapter net = new NetworkAdapter(HelpActivity.this,mHandler, HelpActivity.this);
					Config.NetObject obj = Config.FeedBack.getUrlFeedBack(0,"tester",feedText);
//					net.sendHttpGet(ConnectActivity.METHOD_POST_FEEDBACK, obj.url, obj.param,true);
					net.sendHttpPost(METHOD_POST_FEEDBACK, obj.url, obj.param,true);
				};
			}.start();
			break;

		default:
			break;
		}
	}

	@Override
	public void onResponse(int idMethod, boolean isSuccess, String json) {
			switch (idMethod) {
			case METHOD_POST_FEEDBACK:
				if(isSuccess)
					Toast.makeText(this, getString(R.string.feedback_success), Toast.LENGTH_SHORT).show();
				else
					Toast.makeText(this, getString(R.string.feedback_failed), Toast.LENGTH_SHORT).show();
				this.finish();
				break;

			default:
				break;
			}
	}
}
